package com.lame.sbconstant.product.strategy;

import com.lame.detect.vo.ClassMeta;
import com.lame.sbconstant.product.vo.ProductDesc;
import org.antlr.v4.runtime.Parser;
import org.antlr.v4.runtime.tree.ParseTree;

public class DfServiceImplStrategy extends ProductActorAdapter {

    private String tpl = "${PACKAGE}.service.impl;\n"+
            "import ${BASE_PKG}.entity.${ENTITY};\n"+
            "import ${BASE_PKG}.service.I${ENTITY}Service;\n"+
            "import ${BASE_PKG}.mapper.${ENTITY}Mapper;\n"+
            "import lombok.extern.slf4j.Slf4j;\n"+
            "import org.springframework.stereotype.Service;\n"+
            "import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;\n"+
              "import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;\n" +
            "import com.baomidou.mybatisplus.core.metadata.IPage;\n" +
            "import com.baomidou.mybatisplus.extension.plugins.pagination.Page;\n" +
            "import com.baomidou.mybatisplus.extension.service.IService;\n" +
            "@Service\n" +
            "@Slf4j\n"+
                      "public class ${ENTITY}ServiceImpl extends ServiceImpl<${ENTITY}Mapper,${ENTITY}> implements I${ENTITY}Service{\n" +
                      "}\n";


    @Override
    public String product(Parser parser, ParseTree parseTree, ClassMeta classMeta) {
        return TplTools.generate(classMeta, tpl);
    }

    @Override
    public ProductDesc productDesc(Parser parser, ParseTree parseTree, ClassMeta classMeta) {
        final String generate = TplTools.generate(classMeta, tpl);
        return new ProductDesc("./service/impl/" + classMeta.getName() + "ServiceImpl.java", generate, false);
    }
}
